import { readonly, ref } from "vue";


let timer: NodeJS.Timeout | null
export const useFontSize = () => {
  var currentFontSize = ref(0)
  var screenWidth = ref(0)
  window.addEventListener('resize', () => {
    fun()
  })
  window.addEventListener('load', () => {
    fun()
  })
  const fun = () => {
    screenWidth.value = document.documentElement.clientWidth;
    currentFontSize.value = screenWidth.value / 50 > 30 ? 30 : screenWidth.value / 50 < 14 ? 14 : screenWidth.value / 50;
    console.log(screenWidth.value)
    document.documentElement.style.fontSize = currentFontSize.value + 'px';
  }

  return { currentFontSize, screenWidth, fun }

}